package controller.view;

import java.util.ArrayList;
import java.util.List;

import jgl.GL;
import jgl.GLApplet;
import model.vo.CheckPoint;

public abstract class LimeGLAbtraction extends GLApplet {

	protected List<CheckPoint> checksPoints=new ArrayList<CheckPoint>();	
	
	public LimeGLAbtraction(){
		super.setSize(800, 800);
	}
	
	protected void createScene(){
		for(int x=0;x<=+1600;x+=NLConstants.REF_BASE){
			drawHorizontalStreet((float)x);
			drawVerticalStreet((float)x);
		}
	}
	
	protected void drawHorizontalStreet(float y){
		float thick=50;
		myGL.glColor3f(0f, 0f, 0f);
		myGL.glBegin(GL.GL_QUAD_STRIP);//GL_QUAD_STRIP
			myGL.glVertex3f(0,y,0);
			myGL.glVertex3f(1600,y,0);
			myGL.glVertex3f(0,y+thick,0);
			myGL.glVertex3f(1600,y+thick,0);
		myGL.glEnd();
	}
	
	protected void drawVerticalStreet(float x){
		float thick=50;
		myGL.glColor3f(0f, 0f, 0f);
		myGL.glBegin(GL.GL_QUAD_STRIP);//GL_QUAD_STRIP
			myGL.glVertex3f(x,0,0);
			myGL.glVertex3f(x+thick,0,0);
			myGL.glVertex3f(x,1600,0);
			myGL.glVertex3f(x+thick,1600,0);
		myGL.glEnd();
	}
	
	protected void drawCheckPoints(){
		for(CheckPoint cp:checksPoints){
			
			//memorize prior color
			float red=cp.getRed();
			float green=cp.getGreen();
			float blue=cp.getBlue();
			
			myGL.glColor3f(red, green, blue);
			
			drawCube((float)cp.getPosition().getX(),(float)cp.getPosition().getY());
			
			myGL.glColor3f(1.0f, 0f, 0f);
			
		}
	}
	
	public void drawCube(float x,float y){
		
		myGL.glBegin(GL.GL_QUAD_STRIP);
		myGL.glVertex3f(x,y, 0.0f);
		myGL.glVertex3f(x, y+20, 0.0f);
		myGL.glVertex3f(x+20, y, 0.0f);
		myGL.glVertex3f(x+20, y+20, 0.0f);
		myGL.glEnd();
				
	}
	
}
